package com.chenfan.process.enums;

import lombok.Getter;

/**
 * @author K
 * @date 2021/1/27
 */
@Getter
public enum ProcessEnums {
    /**
     * 审批中
     */
    APPROVING("审批中", 0),
    /**
     * 已撤回
     */
    REVOKE("已取消", 1),
    /**
     * 审批拒绝
     */
    REFUSE("审批拒绝", 2),
    /**
     * 结束
     */
    FINISH("审批通过", 3);

    ProcessEnums(String message, Integer code) {
        this.code = code;
        this.message = message;
    }

    private final Integer code;
    private final String message;

    public static String getMessage(Integer code) {
        for (ProcessEnums processEnums : values()) {
            if (processEnums.code.equals(code)) {
                return processEnums.message;
            }
        }
        return "";
    }

    public static boolean finish(Integer status) {
        return !ProcessEnums.APPROVING.getCode().equals(status);
    }

    public static Integer getApprovalFlag(Boolean approvalFlag) {
        return Boolean.TRUE.equals(approvalFlag) ? ProcessEnums.FINISH.getCode() : ProcessEnums.REFUSE.getCode();
    }
}
